package com.offcn.service;

import com.offcn.dao.Pet_SystemDao;
import com.offcn.dao.Pet_SystemDaoImpl;
import com.offcn.entity.pet_system;
import com.offcn.utlis.PageUtils;

import java.util.List;

public class Pet_SystemServiceImpl implements Pet_SystemService {
    // 调用dao
    Pet_SystemDao pet_systemDao = new Pet_SystemDaoImpl();

    /**
     * 分页查询
     * @param search
     * @param currentPage
     * @param pageSize
     * @return
     */
    @Override
    public PageUtils<pet_system> find(String search, int currentPage, int pageSize) {
        StringBuffer sb = new StringBuffer("select * from pets where pname like ? ");
        int total = pet_systemDao.find(sb.toString(), "%" + search + "%").size();
        sb.append(" limit ?, ? ");
        List<pet_system> pet_systems = pet_systemDao.find(sb.toString(), "%" + search + "%", (currentPage - 1) * pageSize, pageSize);
        PageUtils<pet_system> pageUtils = new PageUtils<pet_system>(pageSize,currentPage,total,pet_systems);
        return pageUtils;
    }

    /**
     * 删除
     * @param pid
     * @return
     */
    @Override
    public boolean delfind(String pid) {
        return  pet_systemDao.delfind(pid)>0;
    }

    /**
     * 修改
     * @param petSystem
     * @return
     */
    @Override
    public boolean updateByid(pet_system petSystem) {
        return pet_systemDao.updateByid(petSystem)>0;
    }

    /**
     * 添加
     * @param petSystem
     * @return
     */
    @Override
    public boolean add(pet_system petSystem) {
        return pet_systemDao.add(petSystem)>0;
    }


}
